package dao;

import common.spring.jdbc.MySQLHelper;
import common.utils.MyMapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import pojo.form.TransfersInfoAddForm;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by asus on 2018/12/2.
 */
@Repository
public class TransfersInfoDao {
    @Autowired
    MySQLHelper sqlHelper;

    public int addTransfersInfo(TransfersInfoAddForm addForm){
        StringBuilder stringBuilder =new StringBuilder();
        stringBuilder.append("insert into transfers_info(name,des,mchAppid,mchid,orderCode,amount,createTime) ");
        stringBuilder.append("values(?,?,?,?,?,?,?)");
        List list = new ArrayList();
        list.add(addForm.getName());
        list.add(addForm.getDesc());
        list.add(addForm.getMchAppid());
        list.add(addForm.getMchid());
        list.add(addForm.getOrderCode());
        list.add(addForm.getAmount());
        list.add(new Date());
        return sqlHelper.insert(stringBuilder.toString(),list.toArray());
    }

    public int updateTransfersInfo(String paymentNo,String paymentTime,String orderCode){
        return  sqlHelper.update("update transfers_info set paymentNo=?,paymentTime=?  where orderCode=? ",new Object[]{paymentNo,paymentTime,orderCode});
    }
}
